<?php

/**
 * 
 *
 * @version $Id: regist.inc.php,v 1.8 2004/12/31 14:35:57 phppc Exp $
 * @copyright 2004 
 **/

$this->uf_field[1] = "user_name";
	$this->uf_input[1]["ml"] = 40;
	$this->uf_input[1]["size"] = 20;
$this->uf_field[2] = "email";
	$this->uf_input[2]["ml"] = 50;
	$this->uf_input[2]["size"] = 20;
if ($this->db_config["pw_mode"] == 1) {
    $this->uf_field[3] = "pw";
		$this->uf_input[3]["type"] = "password";
	$this->uf_field[4] = "pw_conf";
		$this->uf_input[4]["type"] = "password";
}

$regist = $this->fun_sg2var("regist");
$regist = $this->uf_form_conf_def($regist,array("new","do"),"new");

if ($this->db_config["regist_option"] > 0 AND $this->db_config["regist_option"] <= 3) {
    if ($regist == "new") {
    	$this->module_new_value["action"] = "regist";
		$hidden_array = array("regist" => "do");
		$nc_main = $this->uf_create_complete_form("regist_title", $hidden_array, "regist_submit", "form_reset", "complete_form", "uf/", "", "", "regist_");
	}elseif($regist == "do") {
		$valid_regist = 0;
		list($valid_array,$abfrage) = $this->uf_create_array_conf();
		if ($this->uf_form_conf($valid_array) == 1) {
		    if ($this->db_anzahl_zeilen("SELECT id FROM ".$this->config["db_table_user"]." WHERE user_name=\"".htmlentities($_POST["user_name"])."\"") == 0) {
		        if ($this->db_anzahl_zeilen("SELECT id FROM ".$this->config["db_table_user"]." WHERE email=\"".stripslashes(htmlentities($_POST["email"]))."\"") == 0) {
			    	if (($_POST["pw"] == $_POST["pw_conf"]) OR $this->db_config["pw_mode"] == 0) {
						if ($this->db_config["pw_mode"] == 0) $_POST["pw"] = $this->fun_random_value($this->user_pw_length);
						$act_key = $this->fun_random_value($this->user_act_key_length);
						$this->session_user_create($_POST["user_name"],$_POST["pw"],$_POST["email"],$this->db_config["standard_perm"],$act_key);
						$new_user_id = $this->db_insert_id();
						$this->message_green[] = 140;
						$pfad = $this->fun_make_link($this->config["http_pfad"],"",0);
						$replace_array = array("%pfad%" => $pfad,"%user_name%" => $_POST["user_name"],"%user_pw%" => $_POST["pw"]);
						if ($this->db_config["regist_option"] == 3) {
							$this->message_green[] = 142;
						}elseif ($this->db_config["regist_option"] == 2) {
							$this->message_green[] = 141;
							$this->module_new_value["action"] = "act";
							$act_pfad = $this->fun_make_link("","act=do&act_key=".$act_key."&uid=".$new_user_id."",0);
							$replace_array["%act_key%"] = $act_key;
							$replace_array["%act_pfad%"] = $act_pfad;
						}
						$email_subject = "regist_email_subject";
						$this->fun_send_email($_POST["email"],"armin@phppc.de",$email_subject,"regist_email_message_act",$replace_array);
						$valid_regist = 1;
				    }else $this->message_red[] = 92;
				}else $this->message_red[] = 93;
		    }else $this->message_red[] = 90;
		}else $this->message_red[] = 1;
		if($valid_regist != 1) {
			$this->message_red[] = 94;
			$this->w_leitung["number"] = 1;
		}
	}
}

?>